package com.example.demo.mapper;


import com.example.demo.entity.Authority;
import com.example.demo.entity.Customer;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface CustomerMapper {

    @Select("select username,password,valid from t_customer where username=#{username} ")
    public Customer getCustomer(String username);


    @Select("select c.username, a.authority from t_customer c, t_authority a, t_customer_authority" +
            " ac where  c.id=ac.customer_id and a.id=ac.authority_id and c.username=#{username}")
    public List<Authority> getAuthoris(String username);


    @Insert("insert into t_customer values(0,#{username},#{password},#{valid})")
    public int registerUser(Customer customer);
}
